package com.gzhu.knowledgeAdmin.controller;


import com.gzhu.knowledgeAdmin.common.result.R;
import com.gzhu.knowledgeAdmin.entity.TQjszT;
import com.gzhu.knowledgeAdmin.service.GlobalSettingService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/globalsetting")
public class GlobalSettingController {

    @Resource
    private GlobalSettingService globalSettingService;

    @PostMapping("/save/{fGsid}")
    public R saveTask(@PathVariable String fGsid, @RequestBody TQjszT tQjszT)
    {

        Integer count = globalSettingService.countByGsid(fGsid);
        if(count==0)
        {
            return R.ok(globalSettingService.insertGlobalSetting(tQjszT));
        }else {
            return R.ok(globalSettingService.updateGlobalSetting(tQjszT));
        }
    }


    @GetMapping("/find/{fGsid}")
    public R findByGsid(@PathVariable String fGsid)
    {
        return R.ok(globalSettingService.findByGsid(fGsid));
    }
}
